home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktimeintro / play movie / application files / comapplication.c next >
Encoding:
Text File  |  2000-10-06  |  18.4 KB  |  707 lines

  1. //////////
  2. //
  3. //    File:        ComApplication.c
  4. //
  5. //    Contains:    Application-specific code for basic QuickTime movie display and control.
  6. //
  7. //    Written by:    Tim Monroe
  8. //                Based on the QTShell code written by Tim Monroe, which in turn was based on the MovieShell
  9. //                code written by Kent Sandvik (Apple DTS). This current version is now very far removed from
  10. //                MovieShell.
  11. //
  12. //    Copyright:    © 1999 by Apple Computer, Inc., all rights reserved.
  13. //
  14. //    Change History (most recent first):
  15. //       
  16. //       <2>         03/02/00    rtm        made changes to get things running under CarbonLib
  17. //       <1>         11/05/99    rtm        first file
  18. //
  19. //////////
  20.  
  21. //////////
  22. //
  23. // header files
  24. //
  25. //////////
  26.  
  27. #include "ComApplication.h"
  28. #include "PMUtilities.h"
  29.  
  30.  
  31. //////////
  32. //
  33. // global variables
  34. //
  35. //////////
  36.  
  37. #if TARGET_OS_MAC
  38. AEEventHandlerUPP        gHandleOpenAppAEUPP;                    // UPPs for our Apple event handlers
  39. AEEventHandlerUPP        gHandleOpenDocAEUPP;
  40. AEEventHandlerUPP        gHandlePrintDocAEUPP;
  41. AEEventHandlerUPP        gHandleQuitAppAEUPP;
  42. extern Boolean            gAppInForeground;                        // is our application in the foreground?    
  43. #endif
  44.  
  45. #if TARGET_OS_WIN32
  46. extern HWND                ghWnd;                                    // the MDI frame window; this window has the menu bar
  47. #endif
  48.  
  49.  
  50. //////////
  51. //
  52. // QTApp_Init
  53. // Do any application-specific initialization.
  54. //
  55. // The theStartPhase parameter determines which "phase" of application start-up is executed,
  56. // *before* the MDI frame window is created or *after*. This distinction is relevant only on
  57. // Windows, so on MacOS, you should always use kInitAppPhase_BothPhases.
  58. //
  59. //////////
  60.  
  61. void QTApp_Init (UInt32 theStartPhase)
  62. {
  63.     // do any start-up activities that should occur before the MDI frame window is created
  64.     if (theStartPhase & kInitAppPhase_BeforeCreateFrameWindow) {
  65. #if TARGET_OS_MAC
  66.         // make sure that the Apple Event Manager is available; install handlers for required Apple events
  67.         QTApp_InstallAppleEventHandlers();
  68. #endif
  69.     }
  70.  
  71.     // do any start-up activities that should occur after the MDI frame window is created
  72.     if (theStartPhase & kInitAppPhase_AfterCreateFrameWindow) {
  73. #if TARGET_OS_WIN32
  74.         // on Windows, open as movie documents any files specified on the command line
  75.         SendMessage(ghWnd, WM_OPENDROPPEDFILES, 0L, 0L);
  76. #endif
  77.     }
  78. }
  79.  
  80.  
  81. //////////
  82. //
  83. // QTApp_Stop
  84. // Do any application-specific shut-down.
  85. //
  86. // The theStopPhase parameter determines which "phase" of application shut-down is executed,
  87. // *before* any open movie windows are destroyed or *after*.
  88. //
  89. //////////
  90.  
  91. void QTApp_Stop (UInt32 theStopPhase)
  92. {    
  93.     // do any shut-down activities that should occur before the movie windows are destroyed
  94.     if (theStopPhase & kStopAppPhase_BeforeDestroyWindows) {
  95.         
  96.     }
  97.     
  98.     // do any shut-down activities that should occur after the movie windows are destroyed
  99.     if (theStopPhase & kStopAppPhase_AfterDestroyWindows) {
  100. #if TARGET_OS_MAC
  101.         // dispose of routine descriptors for Apple event handlers
  102.         DisposeAEEventHandlerUPP(gHandleOpenAppAEUPP);
  103.         DisposeAEEventHandlerUPP(gHandleOpenDocAEUPP);
  104.         DisposeAEEventHandlerUPP(gHandlePrintDocAEUPP);
  105.         DisposeAEEventHandlerUPP(gHandleQuitAppAEUPP);
  106. #endif
  107.     
  108.     }
  109. }
  110.  
  111.  
  112. //////////
  113. //
  114. // QTApp_Idle
  115. // Do any processing that can/should occur at idle time.
  116. //
  117. //////////
  118.  
  119. void QTApp_Idle (WindowReference theWindow)
  120. {
  121.     WindowObject         myWindowObject = NULL;
  122.     GrafPtr             mySavedPort;
  123.     
  124.     GetPort(&mySavedPort);
  125.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  126.     
  127.     myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  128.     if (myWindowObject != NULL) {
  129.         MovieController        myMC = NULL;
  130.         Movie                myMovie = NULL;
  131.     
  132.         myMovie = (**myWindowObject).fMovie;
  133.         myMC = (**myWindowObject).fController;
  134.         if (myMC != NULL) {
  135.             
  136.             // run any idle-time tasks for the movie
  137.             
  138. #if TARGET_OS_MAC
  139.             // restore the cursor to the arrow
  140.             // if it's outside the front movie window or outside the window's visible region
  141.             if (theWindow == QTFrame_GetFrontMovieWindow()) {
  142.                 Rect            myRect;
  143.                 Point            myPoint;
  144.                 RgnHandle        myVisRegion;
  145.                 Cursor            myArrow;
  146.                 
  147.                 GetMouse(&myPoint);
  148.                 myVisRegion = NewRgn();
  149.                 GetPortVisibleRegion(QTFrame_GetPortFromWindowReference(theWindow), myVisRegion);
  150.                 GetWindowPortBounds(theWindow, &myRect);
  151.                 if (!MacPtInRect(myPoint, &myRect) || !PtInRgn(myPoint, myVisRegion))
  152.                     MacSetCursor(GetQDGlobalsArrow(&myArrow));
  153.                     
  154.                 DisposeRgn(myVisRegion);
  155.  
  156.             }
  157. #endif // TARGET_OS_MAC
  158.         } else if ( myMovie != NULL ) {
  159.             MoviesTask(myMovie, DoTheRightThing);
  160.         }
  161.     }
  162.     
  163.     // ***insert application-specific idle-time processing here***
  164.     
  165.     MacSetPort(mySavedPort);
  166. }
  167.  
  168.  
  169. //////////
  170. //
  171. // QTApp_Draw
  172. // Update the specified window.
  173. //
  174. //////////
  175.  
  176. void QTApp_Draw (WindowReference theWindow, Rect *theRefreshArea)
  177. {
  178. #pragma unused(theRefreshArea)
  179.  
  180.     GrafPtr             mySavedPort;
  181.     MovieController        myMC = NULL;
  182.     
  183.     GetPort(&mySavedPort);
  184.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  185.     
  186.     BeginUpdate(QTFrame_GetWindowFromWindowReference(theWindow));
  187.     //EraseRect(theRefreshArea);        // this is important only for non-rectangular movies
  188.     
  189.     // ***insert application-specific drawing here***
  190.     
  191.     // draw the movie controller and its movie
  192.     myMC = QTFrame_GetMCFromWindow(theWindow);
  193.     if (myMC) {
  194.         MCDoAction(myMC, mcActionDraw, theWindow);
  195.     } else {
  196.         WindowObject myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  197.         if (myWindowObject != NULL) {
  198.             Movie myMovie = (**myWindowObject).fMovie;
  199.             UpdateMovie(myMovie);
  200.         }
  201.     }
  202.     
  203.     EndUpdate(QTFrame_GetWindowFromWindowReference(theWindow));
  204.     MacSetPort(mySavedPort);
  205. }
  206.  
  207.  
  208. //////////
  209. //
  210. // QTApp_HandleContentClick
  211. // Handle mouse button clicks in the specified window.
  212. //
  213. //////////
  214.  
  215. void QTApp_HandleContentClick (WindowReference theWindow, EventRecord *theEvent)
  216. {
  217. #pragma unused(theEvent)
  218.  
  219.     GrafPtr             mySavedPort;
  220.     
  221.     GetPort(&mySavedPort);
  222.     MacSetPort(QTFrame_GetPortFromWindowReference(theWindow));
  223.     
  224.     // ***insert application-specific content-click processing here***
  225.     
  226.     WindowObject theWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  227.     
  228.     if ((**theWindowObject).fMovie != NULL) {
  229.         Movie myMovie = (**theWindowObject).fMovie;
  230.         if (GetMovieRate(myMovie)) {
  231.             StopMovie(myMovie);
  232.         } else {
  233.         
  234.             if (IsMovieDone(myMovie))
  235.                 GoToBeginningOfMovie(myMovie);
  236.             
  237.             if (QTUtils_IsStreamedMovie(myMovie)) {
  238.                         PrePrerollMovie(myMovie,                        // Movie specifier
  239.                                         GetMovieTime(myMovie, NULL),    // Starting time
  240.                                         GetMoviePreferredRate(myMovie),    // Anticipated movie playback rate
  241.                                         gMoviePPRollCompleteProc,        // Compleation procedure
  242.                                         (void *)theWindowObject);        // Reference constant
  243.             } else {
  244.                 PrerollAndPlay(myMovie);
  245.             }
  246.         }
  247.     }
  248.         
  249.  
  250.     MacSetPort(mySavedPort);
  251. }
  252.  
  253.  
  254. //////////
  255. //
  256. // QTApp_HandleKeyPress
  257. // Handle application-specific key presses.
  258. // Returns true if the key press was handled, false otherwise.
  259. //
  260. //////////
  261.  
  262. Boolean QTApp_HandleKeyPress (char theCharCode)
  263. {
  264.     Boolean        isHandled = true;
  265.     WindowReference theWindow = FrontWindow();
  266.     Movie    theMovie = NULL;
  267.     
  268.     WindowObject theWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  269.     if (theWindowObject != NULL ) {
  270.         theMovie = (**theWindowObject).fMovie;
  271.             if ( theMovie == NULL ) return false;
  272.     } else {
  273.         return false;
  274.     }
  275.     
  276.     long theLoopingInfo = 0;    
  277.     
  278.     switch (theCharCode) {
  279.     
  280.         case 0x0D:
  281.             QTUtils_GetMovieFileLoopingInfo(theMovie, &theLoopingInfo);
  282.             if (theLoopingInfo == 2) {
  283.                 StopMovie(theMovie);
  284.                 GoToBeginningOfMovie(theMovie);
  285.                 if (QTUtils_IsStreamedMovie (theMovie)) {
  286.                         PrePrerollMovie(theMovie,                        // Movie specifier
  287.                                         0,                                // Starting time
  288.                                         GetMoviePreferredRate(theMovie),    // Anticipated movie playback rate
  289.                                         gMoviePPRollCompleteProc,        // Compleation procedure
  290.                                         (void *)theWindowObject);        // Reference constant
  291.                 } else {
  292.                     PrerollAndPlay(theMovie);
  293.                 }
  294.             }
  295.             
  296.             isHandled = true;
  297.             break;
  298.             
  299.         case 0x20:
  300.             QTUtils_GetMovieFileLoopingInfo(theMovie, &theLoopingInfo);
  301.             if (theLoopingInfo == 2) {
  302.                 if (!QTUtils_IsStreamedMovie (theMovie)) {
  303.                     Fixed myPlayRate = GetMovieRate(theMovie);
  304.                     myPlayRate = myPlayRate * -1;
  305.                     SetMovieRate(theMovie, myPlayRate);
  306.                 }
  307.             }
  308.             
  309.             isHandled = true;
  310.             break;    
  311.  
  312.         default:
  313.             isHandled = false;
  314.             break;
  315.     }
  316.  
  317.     return(isHandled);
  318. }
  319.  
  320.  
  321. //////////
  322. //
  323. // QTApp_HandleMenu
  324. // Handle selections in the application's menus.
  325. //
  326. // The theMenuItem parameter is a UInt16 version of the Windows "menu item identifier". 
  327. // When called from Windows, theMenuItem is simply the menu item identifier passed to the window procedure.
  328. // When called from MacOS, theMenuItem is constructed like this:
  329. //     *high-order 8 bits == the Macintosh menu ID (1 thru 256)
  330. //     *low-order 8 bits == the Macintosh menu item (sequential from 1 to ordinal of last menu item in menu)
  331. // In this way, we can simplify the menu-handling code. There are, however, some limitations, mainly that
  332. // the menu item identifiers on Windows must be derived from the Mac values. 
  333. //
  334. //////////
  335.  
  336. Boolean QTApp_HandleMenu (UInt16 theMenuItem)
  337. {
  338.     WindowObject        myWindowObject = NULL;
  339.     MovieController     myMC = NULL;
  340.     Movie                 myMovie = NULL;
  341.     Boolean                myIsHandled = false;            // false => allow caller to process the menu item
  342.     
  343.     myWindowObject = QTFrame_GetWindowObjectFromFrontWindow();
  344.     if (myWindowObject != NULL) {
  345.         myMC = (**myWindowObject).fController;
  346.         myMovie = (**myWindowObject).fMovie;
  347.     }
  348.     
  349.     // make sure we have a valid movie controller
  350.     if (myMC == NULL)
  351.         return(myIsHandled);
  352.  
  353.     switch (theMenuItem) {
  354.     
  355.         case IDM_CONTROLLER:
  356.             QTUtils_ToggleControllerBar(myMC);
  357.             myIsHandled = true;
  358.             break;
  359.  
  360.         case IDM_SPEAKER_BUTTON:
  361.             QTUtils_ToggleControllerButton(myMC, kQTUtilsSpeakerButton);
  362.             myIsHandled = true;
  363.             break;
  364.             
  365.         default:
  366.             break;
  367.             
  368.     } // switch (theMenuItem)
  369.     
  370.     return(myIsHandled);
  371. }
  372.  
  373.  
  374. //////////
  375. //
  376. // QTApp_AdjustMenus
  377. // Adjust state of items in the application's menus.
  378. //
  379. // Currently, the Mac application has only one app-specific menu ("Test"); you could change that.
  380. //
  381. //////////
  382.  
  383. void QTApp_AdjustMenus (WindowReference theWindow, MenuReference theMenu)
  384. {
  385. #if TARGET_OS_MAC
  386. #pragma unused(theMenu)
  387. #endif
  388.  
  389.     WindowObject        myWindowObject = NULL; 
  390.     MovieController     myMC = NULL;
  391.     MenuReference        myMenu;
  392.     
  393. #if TARGET_OS_WIN32
  394.     myMenu = theMenu;
  395. #endif
  396. #if TARGET_OS_MAC
  397.     myMenu = GetMenuHandle(kTestMenuResID);
  398. #endif
  399.     
  400.     if (theWindow != NULL)
  401.         myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow);
  402.  
  403.     if (myWindowObject != NULL)
  404.         myMC = (**myWindowObject).fController;
  405.  
  406.     // ***insert application-specific menu adjusting here***
  407.  
  408.     if (myMC == NULL) {
  409.         // no movie controller, so disable all the Test menu items
  410.         QTFrame_SetMenuItemState(myMenu, IDM_CONTROLLER, kDisableMenuItem);
  411.         QTFrame_SetMenuItemState(myMenu, IDM_SPEAKER_BUTTON, kDisableMenuItem);
  412.     } else {
  413.         // we've got a movie controller, so it's safe to proceed....
  414.         QTFrame_SetMenuItemState(myMenu, IDM_CONTROLLER, kEnableMenuItem);
  415.  
  416.         // if controller bar is visible, enable Test menu items
  417.         if (QTUtils_IsControllerBarVisible(myMC)) {
  418.             QTFrame_SetMenuItemLabel(myMenu, IDM_CONTROLLER, "Hide &Controller");
  419.                // ungray the other menu items
  420.             QTFrame_SetMenuItemState(myMenu, IDM_SPEAKER_BUTTON, kEnableMenuItem);
  421.             
  422.             // handle Test menu items
  423.             if (QTUtils_IsControllerButtonVisible(myMC, kQTVRSpeakerButton))
  424.                 QTFrame_SetMenuItemLabel(myMenu, IDM_SPEAKER_BUTTON, "Hide Spea&ker Button");
  425.             else 
  426.                 QTFrame_SetMenuItemLabel(myMenu, IDM_SPEAKER_BUTTON, "Show Spea&ker Button");
  427.             
  428.         } else {
  429.             // controller bar is not visible
  430.             
  431.             QTFrame_SetMenuItemLabel(myMenu, IDM_CONTROLLER, "Show &Controller");
  432.               // gray the other menu items
  433.             QTFrame_SetMenuItemState(myMenu, IDM_SPEAKER_BUTTON, kDisableMenuItem);
  434.         }
  435.     }
  436. }
  437.  
  438.  
  439. //////////
  440. //
  441. // QTApp_HandleEvent
  442. // Perform any application-specific event loop actions.
  443. //
  444. // Return true to indicate that we've completely handled the event here, false otherwise.
  445. //
  446. //////////
  447.  
  448. Boolean QTApp_HandleEvent (EventRecord *theEvent)
  449. {
  450. #pragma unused (theEvent)
  451.     // ***insert application-specific event handling here***
  452.     
  453.     return(false);            // no-op for now
  454. }
  455.  
  456.  
  457. //////////
  458. //
  459. // QTApp_SetupController
  460. // Configure the movie controller.
  461. //
  462. //////////
  463.  
  464. void QTApp_SetupController (MovieController theMC)
  465. {
  466.     long            myControllerFlags;
  467.     
  468.     // CLUT table use
  469.     MCDoAction(theMC, mcActionGetFlags, &myControllerFlags);
  470.     MCDoAction(theMC, mcActionSetFlags, (void *)(myControllerFlags | mcFlagsUseWindowPalette));
  471.  
  472.     // enable keyboard event handling
  473.     MCDoAction(theMC, mcActionSetKeysEnabled, (void *)true);
  474.     
  475.     // disable drag support
  476.     MCDoAction(theMC, mcActionSetDragEnabled, (void *)false);
  477. }
  478.  
  479.  
  480. //////////
  481. //
  482. // QTApp_SetupWindowObject
  483. // Do any application-specific initialization of the window object.
  484. //
  485. //////////
  486.  
  487. void QTApp_SetupWindowObject (WindowObject theWindowObject)
  488. {
  489. #pragma unused(theWindowObject)
  490.  
  491.     // ***insert application-specific window object configuration here***
  492. }
  493.  
  494.  
  495. //////////
  496. //
  497. // QTApp_RemoveWindowObject
  498. // Do any application-specific clean-up of the window object.
  499. //
  500. //////////
  501.  
  502. void QTApp_RemoveWindowObject (WindowObject theWindowObject)
  503. {
  504. #pragma unused(theWindowObject)
  505.     
  506.     // ***insert application-specific window object clean-up here***
  507.  
  508.     // QTFrame_DestroyMovieWindow in MacFramework.c or QTFrame_MovieWndProc in WinFramework.c
  509.     // releases the window object itself
  510. }
  511.  
  512.  
  513. //////////
  514. //
  515. // QTApp_MCActionFilterProc 
  516. // Intercept some actions for the movie controller.
  517. //
  518. // NOTE: The theRefCon parameter is a handle to a window object record.
  519. //
  520. //////////
  521.  
  522. PASCAL_RTN Boolean QTApp_MCActionFilterProc (MovieController theMC, short theAction, void *theParams, long theRefCon)
  523. {
  524. #pragma unused(theMC, theParams)
  525.  
  526.     Boolean                isHandled = false;            // false => allow controller to process the action
  527.     WindowObject        myWindowObject = NULL;
  528.     
  529.     myWindowObject = (WindowObject)theRefCon;
  530.     if (myWindowObject == NULL)
  531.         return(isHandled);
  532.         
  533.     switch (theAction) {
  534.     
  535.         // handle window resizing
  536.         case mcActionControllerSizeChanged:
  537.             if (MCIsControllerAttached(theMC) == 1)
  538.                 QTFrame_SizeWindowToMovie(myWindowObject);
  539.             break;
  540.  
  541.         // handle idle events
  542.         case mcActionIdle:
  543.             QTApp_Idle((**myWindowObject).fWindow);
  544.             break;
  545.             
  546.         default:
  547.             break;
  548.             
  549.     } // switch (theAction)
  550.     
  551.     return(isHandled);    
  552. }
  553.  
  554.  
  555. #if TARGET_OS_MAC
  556. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  557. //
  558. // Apple Event functions.
  559. //
  560. // Use these functions to install handlers for Apple Events and to handle those events.
  561. //
  562. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  563.  
  564. //////////
  565. //
  566. // QTApp_InstallAppleEventHandlers 
  567. // Install handlers for Apple Events.
  568. //
  569. //////////
  570.  
  571. void QTApp_InstallAppleEventHandlers (void)
  572. {
  573.     long        myAttrs;
  574.     OSErr        myErr = noErr;
  575.     
  576.     // see whether the Apple Event Manager is available in the present operating environment;
  577.     // if it is, install handlers for the four required Apple Events
  578.     myErr = Gestalt(gestaltAppleEventsAttr, &myAttrs);
  579.     if (myErr == noErr) {
  580.         if (myAttrs & (1L << gestaltAppleEventsPresent)) {
  581.             // create routine descriptors for the Apple event handlers
  582.             gHandleOpenAppAEUPP = NewAEEventHandlerUPP(QTApp_HandleOpenApplicationAppleEvent);
  583.             gHandleOpenDocAEUPP = NewAEEventHandlerUPP(QTApp_HandleOpenDocumentAppleEvent);
  584.             gHandlePrintDocAEUPP = NewAEEventHandlerUPP(QTApp_HandlePrintDocumentAppleEvent);
  585.             gHandleQuitAppAEUPP = NewAEEventHandlerUPP(QTApp_HandleQuitApplicationAppleEvent);
  586.             
  587.             // install the handlers
  588.             AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gHandleOpenAppAEUPP, 0L, false);
  589.             AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, gHandleOpenDocAEUPP, 0L, false);
  590.             AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, gHandlePrintDocAEUPP, 0L, false);
  591.             AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, gHandleQuitAppAEUPP, 0L, false);
  592.         }
  593.     }
  594. }
  595.         
  596.         
  597. //////////
  598. //
  599. // QTApp_HandleOpenApplicationAppleEvent 
  600. // Handle the open-application Apple Events.
  601. //
  602. //////////
  603.  
  604. PASCAL_RTN OSErr QTApp_HandleOpenApplicationAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, unsigned long theRefcon)            
  605. {
  606. #pragma unused(theMessage, theReply, theRefcon)
  607.     
  608.     // we don't need to do anything special when opening the application
  609.     return(noErr);
  610. }
  611.  
  612.  
  613. //////////
  614. //
  615. // QTApp_HandleOpenDocumentAppleEvent 
  616. // Handle the open-document Apple Events. This is based on Inside Macintosh: IAC, pp. 4-15f.
  617. //
  618. // Here we process an Open Documents AE only for files of type MovieFileType.
  619. //
  620. //////////
  621.  
  622. PASCAL_RTN OSErr QTApp_HandleOpenDocumentAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, unsigned long theRefcon)            
  623. {
  624. #pragma unused(theReply, theRefcon)
  625.  
  626.     long            myIndex;
  627.     long            myItemsInList;
  628.     AEKeyword        myKeyWd;
  629.     AEDescList          myDocList;
  630.     long            myActualSize;
  631.     DescType        myTypeCode;
  632.     FSSpec            myFSSpec;
  633.     OSErr            myIgnoreErr = noErr;
  634.     OSErr            myErr = noErr;
  635.     
  636.     // get the direct parameter and put it into myDocList
  637.     myDocList.dataHandle = NULL;
  638.     myErr = AEGetParamDesc(theMessage, keyDirectObject, typeAEList, &myDocList);
  639.     
  640.     // count the descriptor records in the list
  641.     if (myErr == noErr)
  642.         myErr = AECountItems(&myDocList, &myItemsInList);
  643.     else
  644.         myItemsInList = 0;
  645.     
  646.     // open each specified file
  647.     for (myIndex = 1; myIndex <= myItemsInList; myIndex++)
  648.         if (myErr == noErr) {
  649.             myErr = AEGetNthPtr(&myDocList, myIndex, typeFSS, &myKeyWd, &myTypeCode, (Ptr)&myFSSpec, sizeof(myFSSpec), &myActualSize);
  650.             if (myErr == noErr) {
  651.                 FInfo        myFinderInfo;
  652.             
  653.                 // verify that the file type is MovieFileType; to do this, get the Finder information
  654.                 myErr = FSpGetFInfo(&myFSSpec, &myFinderInfo);    
  655.                 if (myErr == noErr) {
  656.                     if (myFinderInfo.fdType == MovieFileType)
  657.                         // we've got a movie file; just open it
  658.                         QTFrame_OpenMovieInWindow(NULL, &myFSSpec);
  659.                 }
  660.             }
  661.         }
  662.  
  663.     if (myDocList.dataHandle)
  664.         myIgnoreErr = AEDisposeDesc(&myDocList);
  665.     
  666.     // make sure we open the document in the foreground        
  667.     gAppInForeground = true;
  668.     return(myErr);
  669. }
  670.  
  671.  
  672. //////////
  673. //
  674. // QTApp_HandlePrintDocumentAppleEvent 
  675. // Handle the print-document Apple Events.
  676. //
  677. // NOT YET IMPLEMENTED.
  678. //
  679. //////////
  680.  
  681. PASCAL_RTN OSErr QTApp_HandlePrintDocumentAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, unsigned long theRefcon)            
  682. {
  683. #pragma unused(theMessage, theReply, theRefcon)
  684.  
  685.     return(errAEEventNotHandled);
  686. }
  687.  
  688.  
  689. //////////
  690. //
  691. // QTApp_HandleQuitApplicationAppleEvent 
  692. // Handle the quit-application Apple Events.
  693. //
  694. //////////
  695.  
  696. PASCAL_RTN OSErr QTApp_HandleQuitApplicationAppleEvent (const AppleEvent *theMessage, AppleEvent *theReply, unsigned long theRefcon)            
  697. {
  698. #pragma unused(theMessage, theReply, theRefcon)
  699.  
  700.     // close down the entire framework and application
  701.     QTFrame_QuitFramework();
  702.     return(noErr);
  703. }
  704. #endif // TARGET_OS_MAC
  705.  
  706.  
  707.